package day_2022_7_to_8.day48;

/**
 * @author haomin
 * @date 2022/08/26 23:24
 **/
public class Day41_1_Num1464_MaxProduct {
    class Solution0 {
        public int maxProduct(int[] nums) {
            int max = 0;
            for(int i = 0; i < nums.length; ++i){
                for(int j = 0; j != i && j < nums.length; ++j){
                    max = Math.max(max, ((nums[i] - 1) * (nums[j] - 1)));
                }
            }
            return max;
        }
    }
    class Solution {
        public int maxProduct(int[] nums) {
            int max1 = 0, max2 = 0;
            for(int i = 0; i < nums.length; ++i){
                if(nums[i] > max1){
                    max2 = max1;
                    max1 = nums[i];
                }else if (nums[i] > max2){
                    max2 = nums[i];
                }
            }
            return (max1-1) * (max2-1);
        }
    }
}